<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use backend\models\AdminInfo;
use backend\models\Image;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\BuildCitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'vr案例';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="build-city-index">
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <p>
    <?php if(AdminInfo::check_create('create') == true) {?>
        <?= Html::a(Yii::t('app', '创建vr案例'), ['create'], ['class' => 'btn btn-success']) ?>
    <?php }?>	
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'name',
           
            'city',
            'village',
            'house_type',
            'area',
			'cost',
            'brief',
            [
                'attribute'=>'vr_flag','value'=>function($model){
                    return getValueFromArray($model->vr_flag, \backend\models\Vr::$vr_flag);
            },
                'format' => 'raw',
            ],
            [
                'attribute'=>'app_return','value'=>function($model){
                return getValueFromArray($model->app_return, \backend\models\Vr::$app_return);
            },
            'format' => 'raw',
            ],
            'vr_url',
            [
                'attribute'=>'vr_img','value'=>function($model){
               // if(!empty($model->vr_img)) return $model->vr_img."<img width='40px' src='".Image::show_image($model->vr_img)."'>";
                if(!empty($model->vr_img))   return $model->vr_img."<img width='40px' src='".Yii::$app->params['imgPath0'].$model->defaultSmallImage->url."'>";
                
                },
                'format' => 'raw',
             ],
            [
				'class' => 'yii\grid\ActionColumn',
    			'header'=> '浏览',
				'template' => '{view}',
				'buttons' => [
					'view' => function ($url,$model){ 
							return Html::a('<span class="glyphicon glyphicon-eye-open"></span>',Url::to($url),["target"=>"_blank"]);
					}
				]
				
			],
			[
				'class' => 'yii\grid\ActionColumn',
				'header'=> '编辑',
				'template' => '{update}',
				'buttons' => [
					'update' => function ($url,$model){
					if(AdminInfo::check_hasoperator(Yii::$app->user->identity->id,Yii::$app->user->identity->id,'edit'))
							return Html::a('<span class="glyphicon glyphicon-pencil"></span>',Url::to($url),["target"=>"_blank"]);
					}
				]
			
			],
        ],
    ]); ?>

</div>
